package com.artoxian.unused;

import java.io.File;

import org.apache.commons.io.monitor.FileAlterationMonitor;
import org.apache.commons.io.monitor.FileAlterationObserver;

public class FolderMonitor {
    private final FileAlterationMonitor monitor;
    
    public FolderMonitor(File folder) {  	
    	// Create the listener
        FileAlterationListenerImpl listener = new FileAlterationListenerImpl();
        
        // Create the observer
        FileAlterationObserver observer = new FileAlterationObserver(folder);
    	
    	// Set up the monitor with the above listener and observer
        monitor = new FileAlterationMonitor();
        observer.addListener(listener);
        monitor.addObserver(observer);
    }
    
    public void start() throws Exception {
    	monitor.start();
    }
    
    public void stop() throws Exception {
    	monitor.stop();
    }
}
